package com.software.demo5.test;

import com.software.demo5.entity.UserInfo;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class Run {
    public static void main(String[] args) {
        Configuration cfg = new Configuration();
        cfg.configure();

        SessionFactory sessionFactory = cfg.buildSessionFactory();
        Session session = sessionFactory.openSession();

        Transaction transaction = session.beginTransaction();
        //业务逻辑

        UserInfo userInfo = new UserInfo();
        userInfo.setUid(100);
        userInfo.setUserName("class-one-demo5");
        session.save(userInfo);

        transaction.commit();
        session.close();
        sessionFactory.close();
    }
}
